package com.ztrue.test;

import com.ztrue.framework.core.domain.AggregateRoot;

/**
 * @author zhangw
 * @date 2016/12/3 21:56
 * @version: 1.0
 */
public class User extends AggregateRoot<Long> {
    private String name;
    private String sex;

    public User() {

    }

    public User(Long id, String name, String sex) {
        super(id);
        applyEvent(new CreateUserEvent(id, name, sex));
    }

    public void handle(CreateUserEvent event) {
        this.setId(event.getAggregateRootId());
        this.name = event.getName();
        this.sex = event.getSex();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
